/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mobilevikings.util;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
 *
 * @author Jeroen
 */
public class PropertiesFactory
{

    private volatile static Properties mProperties = null;

    /**
     * Returns an instance of the Properties, using the correct propertiesfile
     * @return the properties
     */
    public static Properties getProperties()
    {
        synchronized (PropertiesFactory.class)
        {
            if (mProperties == null)
            {
                mProperties = new Properties();
                String locale = System.getProperty("microedition.locale").substring(0, 2);
                //locale will be "en","nl",...
                try {
                    mProperties.read("/com/mobilevikings/resources/"+locale+".properties");
                } catch(Exception e) {
                    try {
                        mProperties.read("/com/mobilevikings/resources/nl.properties");
                    } catch (Exception ex) {
                        //
                    }
                }
            }
        }
        return mProperties;
    }
}
